package com.zhuang.chapter09.work04;

import java.util.Scanner;

public class TestCustomException {

	public static void main(String[] args) {
		System.out.println(divide());
	}

	public static double divide() {
		Scanner input = new Scanner(System.in);
		double a, b;
		for (;;) {
			try {
				System.out.println("输入第一个整数！");
				a = input.nextDouble();
				System.out.println("输入第二个整数！");
				b = input.nextDouble();
				if (b == 0) {
					throw new CustomException();
				}
				break;
			} catch (CustomException e) {
				e.error();
				System.out.println("重新输入!");
			}
		}
		return a / b;
	}
}
